CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

option(B_MAIN "use main" OFF)

SET(H_ROOT_PATH ../)

SET(H_INCLUDE_PATH ${H_ROOT_PATH}/include)

SET(H_SRC_PATH ${H_ROOT_PATH}/src)

PROJECT(myRec)

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -o2 -w -pthread -ldl -ggdb")

#soundTouch
file(GLOB_RECURSE SOUND_INCLUDE 
${H_SRC_PATH}/soundTouch/*.h
)

file(GLOB_RECURSE SOUND_SRC 
${H_SRC_PATH}/soundTouch/*.cpp)

SOURCE_GROUP(soundTouch\\include FILES ${SOUND_INCLUDE})

SOURCE_GROUP(soundTouch\\source FILES ${SOUND_SRC})

#gips
file(GLOB_RECURSE GIPS_INCLUDE 
${H_SRC_PATH}/gips/webrtc_aec.h
${H_SRC_PATH}/gips/webrtc_agc.h
${H_SRC_PATH}/gips/webrtc_ns.h
${H_SRC_PATH}/gips/webrtc_vad.h
)

file(GLOB_RECURSE GIPS_SRC 
${H_SRC_PATH}/gips/source/*)

SOURCE_GROUP(gips\\include FILES ${GIPS_INCLUDE})

SOURCE_GROUP(gips\\source FILES ${GIPS_SRC})

#base
file(GLOB_RECURSE BASE_INCLUDE 
${H_INCLUDE_PATH}/base/*
)

file(GLOB_RECURSE BASE_SRC 
${H_SRC_PATH}/base/*)

SOURCE_GROUP(base\\include FILES ${BASE_INCLUDE})

SOURCE_GROUP(base\\source FILES ${BASE_SRC})


#voice
file(GLOB_RECURSE VOICE_INCLUDE 
${H_INCLUDE_PATH}/voice/*
)

file(GLOB_RECURSE VOICE_SRC 
${H_SRC_PATH}/voice/*)

SOURCE_GROUP(voice\\include FILES ${VOICE_INCLUDE})

SOURCE_GROUP(voice\\source FILES ${VOICE_SRC})

#video
file(GLOB_RECURSE VIDEO_INCLUDE 
${H_INCLUDE_PATH}/video/*
)

file(GLOB_RECURSE VIDEO_SRC 
${H_SRC_PATH}/video/*)

SOURCE_GROUP(video\\include FILES ${VIDEO_INCLUDE})

SOURCE_GROUP(video\\source FILES ${VIDEO_SRC})

#muxer
file(GLOB_RECURSE MUXER_INCLUDE 
${H_INCLUDE_PATH}/muxer/*
)

file(GLOB_RECURSE MUXER_SRC 
${H_SRC_PATH}/muxer/*)

SOURCE_GROUP(muxer\\include FILES ${MUXER_INCLUDE})

SOURCE_GROUP(muxer\\source FILES ${MUXER_SRC})

#render
file(GLOB_RECURSE RENDER_INCLUDE 
${H_INCLUDE_PATH}/render/*
)

file(GLOB_RECURSE RENDER_SRC 
${H_SRC_PATH}/render/*)

SOURCE_GROUP(render\\include FILES ${RENDER_INCLUDE})

SOURCE_GROUP(render\\source FILES ${RENDER_SRC})

#win-capture
file(GLOB_RECURSE GAME_INCLUDE
${H_SRC_PATH}/win-capture/*.h
)

file(GLOB_RECURSE GAME_SRC
${H_SRC_PATH}/win-capture/*.c*
)

SOURCE_GROUP(game\\include FILES ${GAME_INCLUDE})

SOURCE_GROUP(game\\source FILES ${GAME_SRC})


INCLUDE_DIRECTORIES(
	${H_INCLUDE_PATH}/voice
	${H_INCLUDE_PATH}/base
	${H_INCLUDE_PATH}/ffmpeg_include
	${H_INCLUDE_PATH}/ffmpeg_include/d3d8
	${H_INCLUDE_PATH}/ffmpeg_include/d3dx9_include
	${H_INCLUDE_PATH}/ffmpeg_include/libyuv
	${H_INCLUDE_PATH}/muxer
	${H_INCLUDE_PATH}/video
	${H_INCLUDE_PATH}/render
	
	
	${H_SRC_PATH}/gips
	${H_SRC_PATH}/soundTouch
	${H_SRC_PATH}/win-capture
)
LINK_DIRECTORIES(
	${CMAKE_CURRENT_SOURCE_DIR}/../lib
)


if (B_MAIN)
	ADD_EXECUTABLE(
		${PROJECT_NAME}

		${GIPS_INCLUDE}
		${GIPS_SRC}
		
		${BASE_INCLUDE}
		${BASE_SRC}
		
		${VOICE_INCLUDE}
		${VOICE_SRC}
		
		${MUXER_INCLUDE}
		${MUXER_SRC}
		
		${SOUND_INCLUDE}
		${SOUND_SRC}
		
		${VIDEO_INCLUDE}
		${VIDEO_SRC}
		
		${GAME_INCLUDE}
		${GAME_SRC}
	    
		${RENDER_INCLUDE}
		${RENDER_SRC}
		
		${H_SRC_PATH}/main/main.cpp
	)
else()
	ADD_SUBDIRECTORY(${H_ROOT_PATH}/third/cmake wtl_show)
    SET(LIBRARY_OUTPUT_PATH ${H_ROOT_PATH}/lib)
	ADD_LIBRARY(
		${PROJECT_NAME}
		STATIC
		${GIPS_INCLUDE}
		${GIPS_SRC}
		
		${BASE_INCLUDE}
		${BASE_SRC}
		
		${VOICE_INCLUDE}
		${VOICE_SRC}
		
		${MUXER_INCLUDE}
		${MUXER_SRC}
		
		${SOUND_INCLUDE}
		${SOUND_SRC}
		
		${VIDEO_INCLUDE}
		${VIDEO_SRC}
		
		${GAME_INCLUDE}
		${GAME_SRC}
		
		${RENDER_INCLUDE}
		${RENDER_SRC}
	)
endif()

TARGET_LINK_LIBRARIES(
	${PROJECT_NAME}
	libffmpeg
	libyuv
	d3d11
	winmm
	Strmiids
	comsuppw
	gdiplus
	d3d9
)


